import React, { PureComponent } from 'react';
import { Table } from 'antd';

class GiveBackAddress extends PureComponent {
  render() {
    const { addressList, value, onChange } = this.props;
    const statu = {
      FREE: '包邮',
      PAY: '到付',
      SELF: '自提',
    };
    const columns = [
      {
        title: '手机号码',
        dataIndex: 'telephone',
      },
      {
        title: '收货地址',
        width: 120,
        dataIndex: 'street',
        render: (text, record) => `${record.provinceStr}${record.cityStr}${record.areaStr}${text}`,
      },
      {
        title: '收货人',
        dataIndex: 'name',
      },
      {
        title: '退货快递',
        width: 90,
        dataIndex: 'freightType',
        render: freightType => statu[freightType],
      },
      {
        title: '添加时间',
        dataIndex: 'createTime',
      },
    ];
    const rowSelection = {
      selectedRowKeys: value,
      onChange: selectedRowKeys => {
        onChange(selectedRowKeys);
      },
    };
    return (
      <Table
        rowKey="id"
        columns={columns}
        dataSource={addressList}
        rowSelection={rowSelection}
        pagination={false}
      />
    );
  }
}

export default GiveBackAddress;
